import request from '@/utils/request'
let api = process.env.VUE_APP_PREFIX
// 获取当前用户和名称
export function getLoginUserAndUserDept () {
  return request({
    method: 'get',
    url: `${api}/getLoginUserAndUserDept`,
    params: {
      T: new Date().getTime()
    }
  })
}
// 根据飞机型号和角色获取菜单
export function findMenuByModelAndRoleName (params = {modelName: '', roleName: ''}) {
  return request({
    method: 'get',
    url: `${api}/findMenuByModelAndRoleName`,
    params
  })
}
// 查询常用功能
export function findLevel2Menu (params = {planeModel: '', roleName: '', userId: ''}) {
  params.T = new Date().getTime()
  return request({
    method: 'get',
    url: `${api}/findLevel2Menu`,
    params
  })
}
// 添加常用功能(所有参数都穿),常用APP(最后两个参数不传)
export function addPortalApp (params = {userName: '', planeModel: '', roleName: '', level1Menu: '', addTime: '', level2Menu: '', url: '', icon: '', userId: ''}) {
  var T = new Date().getTime()
  params.T = T
  return request({
    method: 'get',
    url: `${api}/addPortalApp`,
    params
  })
}

// 查询常用APP
export function findLevel1Menu (params = {planeModel: '', roleName: '', userId: ''}) {
  var T = new Date().getTime()
  params.T = T
  return request({
    method: 'get',
    url: `${api}/findLevel1Menu`,
    params
  })
}
// 根据id删除常用功能，常用app
export function deletePortalApp (params = {id: ''}) {
  var T = new Date().getTime()
  params.T = T
  return request({
    method: 'get',
    url: `${api}/deletePortalApp`,
    params
  })
}

// 读取所有图标信息
export function readIcon () {
  return request({
    method: 'get',
    url: `${api}/readIcon`
  })
}
// 修改图标
export function updateIcon (params = {id: '', icon: ''}) {
  var T = new Date().getTime()
  params.T = T
  return request({
    method: 'get',
    url: `${api}/updateIcon`,
    params
  })
}
